$(function () {
    init();
    function init() {
        $.ajax({
            method: "get",
            url: "http://193.112.55.79:9090/api/getcategorytitle",
            dateType: "json",
            success: function (res) {
                var html = template('mmbtp1', res.result);
                $(".classifymenu").html(html);
            }
        });
    }
    
    var flag = true;
    var id;
    $(".classifymenu").on("click", "li", function () {
    if(flag){
        $(this).next().show().siblings("div").hide();
        id = $(this).attr("titleId");
        flag = false;
        $(this).children("span:nth-child(2)").removeClass("glyphicon glyphicon-menu-up").addClass("glyphicon glyphicon-menu-down");
    }else{
        $(this).next().toggle().siblings("div").hide();
        id = $(this).attr("titleId");
         $(this).children("span:nth-child(2)").removeClass("glyphicon glyphicon-menu-up").addClass("glyphicon glyphicon-menu-down");
         $(this).siblings("li").children("span:nth-child(2)").removeClass("glyphicon glyphicon-menu-down").addClass("glyphicon glyphicon-menu-up");
    }
         $.ajax({
             method: "get",
             url: "http://193.112.55.79:9090/api/getcategory",
             data: {
                 titleid: id
             },
             dateType: "json",
             success: function (res) {
                 console.log(res);
                 var html = template('mmbtp2', res.result);
                 $(".menuul").html(html);
             }
         });
    })

   

   


    // 返回顶部
    $(".return").on("click", function () {
        $("html, body").animate({
            scrollTop: 0
        }, 500);
    })
})